<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>[%$softtitle%]</title>
<link href="templates/css/baselist.css" rel="stylesheet" type="text/css" />
<link href="templates/css/all.css" rel="stylesheet" type="text/css" />
<link href="templates/css/formdiv.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/control.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<script type="text/javascript">

	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	};

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodybottonauto")){
			$('.managebottonadd').css({height:h-40});
		}
	}
	var language_js_lng_empty  = "[%$ST.language_js_lng_empty%]";
	var language_js_lngtitle_empty = "[%$ST.language_js_lngtitle_empty%]";
	var language_js_url_err = "[%$ST.language_js_url_err%]";
	var language_js_packname_err = "[%$ST.language_js_packname_err%]";
	var language_js_add_ok = "[%$ST.language_js_add_ok%]";
	var language_js_add_no = "[%$ST.language_js_add_no%]";
	var lngcode_yes = "[%$ST.lngcode_yes%]";
	var lngcode_no = "[%$ST.lngcode_no%]";
	var iframename = "[%$iframename%]";
	iframename = iframename=='' ? "jerichotabiframe_0" : iframename;
	$(document).ready(function(){
		var h = '[%$iframeheightwindow%]';
		$('.managebottonadd').css({height:h-40});
		var options = {

			beforeSubmit: formverify,

			success:saveResponse,
			resetForm: false
		};
		$('#lngadd').submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});
	});




	function formverify(formData) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['lng']==""){
			document.lngadd.lng.focus();
			alert(language_js_lng_empty);
			return false;
		}
		if(get['lng'].match(/^[a-zA-Z]{1}[a-zA-Z]{1,19}$/ig)==null) {
			document.lngadd.lng.focus();
			alert(language_js_lng_empty);
			return false;
		}
		if(get['lngtitle']==""){
			document.lngadd.lngtitle.focus();
			alert(language_js_lngtitle_empty);
			return false;
		}
		if(get['ispack']=="1"){
			if(get['packname'].match(/^[a-zA-Z]{1,39}$/ig)==null) {
				document.lngadd.packname.focus();
				alert(language_js_packname_err);
				return false;
			}
		}
		if(get['url']!=""){

			if(get['url'].match(/^http:\/\/[a-zA-Z.0-9/_]+$/ig)==null) {
				document.lngadd.url.focus();
				alert(language_js_url_err);
				return false;
			}
		}
		parent.windowsdig('Loading','iframe:index.php?archive=management&action=load','400px','180px','iframe',false);
	}
	function saveResponse(options){
		parent.closeifram();
		var tab=document.getElementById("lngaddtab").value;
		if (options=='true'){
			if (tab=='true'){
				if(parent.frames[iframename].document.getElementById("pageinfo")){
					parent.frames[iframename].refresh('selectform','selectall','check_all');
				}
			}
			alert(language_js_add_ok);
		}else{
			alert(language_js_add_no+options);
		}
		if (tab=='true'){
			parent.onaletdoc()
		}
	}

	function checkcode(checktype){
		if(checktype=='lng'){
			var lngadd=document.getElementById("lngvalue").value;
			if(lngadd==""){
				return false;
			}
			var um=document.getElementById('codeerr');
			$.ajax({
				type: "POST",
				url: "index.php?archive=language&action=codedb",
				data: "codename="+lngadd,
				success: function(date){
					if (date=="false"){
						um.innerHTML="<font color=\"red\">"+lngcode_no+"</font>";
						$('#submitbotton').attr('disabled','true');
					}else{
						um.innerHTML="<font color=\"#1CB521\">"+lngcode_yes+"</font>";
						$('#submitbotton').attr('disabled','');
					}
				}
			});
		}else{
			var packname=document.getElementById("packname").value;
			if(packname==""){
				return false;
			}
			var um=document.getElementById('packnameerr');
			$.ajax({
				type: "POST",
				url: "index.php?archive=language&action=codedb&ispack=1",
				data: "packname="+packname,
				success: function(date){
					if (date=="false"){
						um.innerHTML="<font color=\"red\">"+lngcode_no+"</font>";
						$('#submitbotton').attr('disabled','true');
					}else{
						um.innerHTML="<font color=\"#1CB521\">"+lngcode_yes+"</font>";
						$('#submitbotton').attr('disabled','');
					}
				}
			});
		}

	}
</script>
</head>

<body>
<form name="lngadd" id="lngadd" method="post" action="index.php?archive=language&action=lngsave">
<input type="hidden" name="inputclass" value="add">
<input type="hidden" name="tab" id="lngaddtab" value="[%$tab%]">
<div id="mainbodybottonauto" class="managebottonadd">
	<div class="maindobycontent">
		<div class="suggestion">
			<span class="sugicon"><span class="strong colorgorning2">[%$ST.position_title%]</span><span class="colorgorningage">[%$ST.language_add_mess%]</span></span>
		</div>
		<div class="manageeditdiv">
			<div class="maneditcontent">
				<table class="formtable">
					<tr class="trstyle2">
						<td class="trtitle011">[%$ST.language_add_lng%]</td>
						<td class="trtitle02"><input type="text" name="lng" id="lngvalue" size="25" maxlength="20" class="infoInput" onblur="checkcode('lng');"/> <span id="codeerr" class="cautiontitle">[%$ST.language_add_lng_mess%]</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle011">[%$ST.language_add_lngtitle%]</td>
						<td class="trtitle02"><input type="text" name="lngtitle" size="25" maxlength="50"  class="infoInput"/> <span class="cautiontitle">[%$ST.language_add_lngtitle_mess%]</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">[%$ST.language_add_ispack%]</td>
						<td class="trtitle02">
							<input type="radio" value="1" name="ispack" onclick="ondisplay('validatetextdiv','trstyle2 displaytrue')"/> [%$ST.open_botton_title%]&nbsp;
							<input type="radio" value="0" name="ispack" checked="checked" onclick="ondisplay('validatetextdiv','trstyle2 displaynone')"/> [%$ST.close_botton_title%]
							<span class="cautiontitle">[%$ST.language_add_ispack_mess%]</span>
						</td>
					</tr>
					<tr class="trstyle2 displaynone" id="validatetextdiv">
						<td class="trtitle011">[%$ST.language_add_packname%]</td>
						<td  class="trtitle02"><input type="text" name="packname" id="packname" size="25" maxlength="40" class="infoInput" onblur="checkcode('packname');"/> <span id="packnameerr" class="cautiontitle">[%$ST.language_add_packname_mess%]</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">[%$ST.language_add_url%]</td>
						<td class="trtitle02"><input type="text" name="url" size="50" maxlength="100"  class="infoInput"/> <span class="cautiontitle">[%$ST.language_add_url_mess%]</span></td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle01">[%$ST.iswap_title%]</td>
						<td class="trtitle02">
							<input type="radio" value="1" name="iswap"/> [%$ST.open_botton_title%]&nbsp;
							<input type="radio" value="0" name="iswap" checked="checked"/> [%$ST.close_botton_title%]
							<span class="cautiontitle">[%$ST.iswap_title_mess%]</span>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="downbotton">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr>
				<td id="right"><input type="submit" id="submitbotton" name="Submit" value="[%$ST.botton_add%]" class="button orange" /></td>
				<td id="left" class="padding-left5"><input type="button" name="cancel" onClick="javascript:parent.onaletdoc();" value="[%$ST.botton_add_reset%]" class="button orange" /></td>
			</tr>
		</table>
	</div>
</div>
</form>
</body>

</html>